package com.huadao.cart_ccs.data.source.http;

import android.os.Build;
import android.support.annotation.RequiresApi;

import java.util.Objects;

import io.reactivex.functions.Function;

public class HttpFunction<T> implements Function<BaseResponse<T>,T> {
    @RequiresApi(api = Build.VERSION_CODES.KITKAT)
    @Override
    public T apply(BaseResponse<T> response) throws Exception {
        if (!response.isRequestSuccess()) {
            throw new ApiException(response.getCode(), String.valueOf(response.getMessage()));
        }
        return response.getData();
    }
}
